package model;

import java.io.File;
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import data.Project;
public class Pharser {
	public static final String[] fnames = {"required software reliability","data base size","process complexity",
		"time constraint for cpu","main memory constraint","machine volatility","turnaround time",
		"analysts capability","application experience","programmers capability","virtual machine experience",
		"language experience","modern programing practices","use of software tools","schedule constraint",
		"Project Size","Actual effort(months)"};

	public static final Map<String, double[]> parameterValues;
	static{
		 Map<String, double[]> aMap = new  HashMap<String, double[]>();
		 aMap.put(fnames[0],new double[]{0.75,0.85,1,1.15,1.4,1.6});//,-1.87
		 aMap.put(fnames[1],new double[]{0.8,0.94,1,1.08,1.16,1.2});//,-1.23
		 aMap.put(fnames[2],new double[]{0.7,0.85,1,1.15,1.30,1.65});//,-2.36
		 aMap.put(fnames[3],new double[]{0.7,0.9,1,1.11,1.3,1.5});//,-1.49
		 aMap.put(fnames[4],new double[]{0.8,0.9,1,1.06,1.21,1.56});//,-1.21
		 aMap.put(fnames[5],new double[]{0.7,0.87,1,1.15,1.3,1.5});//,-1.49
		 aMap.put(fnames[6],new double[]{0.7,0.87,1,1.07,1.15,1.3});//,-1.32
		 aMap.put(fnames[7],new double[]{1.45,1.19,1,0.86,0.71,0.5});//,2.06
		 aMap.put(fnames[8],new double[]{1.29,1.13,1,0.91,0.82,0.7});//,1.57
		 aMap.put(fnames[9],new double[]{1.42,1.17,1,0.86,0.7,0.5});//,1.67
		 aMap.put(fnames[10],new double[]{1.21,1.10,1,0.9,0,0.8});//,1.34
		 aMap.put(fnames[11],new double[]{1.14,1.07,1,0.95,0.8,0.7});//,1.2
		 aMap.put(fnames[12],new double[]{1.24,1.10,1,0.91,0.82,0.7});//,1.34
		 aMap.put(fnames[13],new double[]{1.24,1.10,1,0.91,0.83,0.7});//,1.49
		 aMap.put(fnames[14],new double[]{1.23,1.08,1.00,1.04,1.1,1.2});//,2.71828
		 parameterValues = aMap;
	}
	private List<Project> projects = new ArrayList<Project>();	
	
	
	public Pharser(String filePath){
		//System.out.println(System.getProperty("user.dir"));
		readFromFile(filePath);
		//readFromFile("src/model/testdata.txt");
		//System.out.println(reg[2][2].toString());
	}
	
	public List<Project> projects() {
		return projects;
	}
	
	/** L�ser registret fr�n filen med namn fileName. */
    public void readFromFile(String filename) {
        Scanner scan = null;
        try {
            scan = new Scanner(new File(filename));
        } catch (FileNotFoundException e) {
            System.err.println("Filen kunde inte �ppnas " + e);
            System.exit(1);
        }
        
        while(scan.hasNext()){
        	String[] temp = scan.nextLine().split(",");
        	String[] t2 = new String[temp.length-1];
        	
        	System.arraycopy(temp, 0, t2, 0, t2.length);
        	
        	projects.add(new Project( t2));
        }
    }
}
